﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout_lay_admin.cshtml";
}
<style>
    body {
        background-color: #ffffff;
    }
</style>

<div class="layui-form layuimini-form">

    <div class="layui-form-item" style="display:none">
        <label class="layui-form-label ">代码</label>
        <div class="layui-input-block">
            <input type="text" name="Organization_ParentId" id="Organization_ParentId"  class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">职位名称</label>
        <div class="layui-input-block">
            <input type="text" name="Organization_Name" lay-verify="required" lay-reqtext="账户不能为空" placeholder="请输入名称" value="" autocomplete="off" class="layui-input">
        </div>
    </div>



    <div class="layui-form-item">
        <label class="layui-form-label">顺序</label>
        <div class="layui-input-block">
            <input type="text" name="Organization_Sort" placeholder="请输入顺序" value="@ViewBag.Sort" autocomplete="off"  onkeyup="value=value.replace(/[^\d]/g, '')" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">备注信息</label>
        <div class="layui-input-block">
            <textarea name="Organization_Remark" class="layui-textarea" placeholder="请输入备注信息"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>

<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

         

        $("#Organization_ParentId").val(GetQueryString("parentid"));

        //监听提交
        form.on('submit(saveBtn)', function (data) {
          

            $.ajax({
                url: '/Base_Organization/Create',
                type: 'post',
                dataType: 'text',
                data: data.field,
                success: function (resp) {
                    var json = eval('(' + resp + ')');
                    var index = layer.alert(json.Message, function () {
                        // 关闭弹出层
                        layer.close(index);
                        parent.reloadTable();
                        var iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(iframeIndex);
                    });
                    //layer.alert(json.Message);
                    //reloadTable();
                },
                error: function (resp) {
                    layer.alert("对不起出错了");
                }
            });


            //var index = layer.alert(JSON.stringify(data.field), {
            //    title: '最终的提交信息'
            //}, function () {
            //    // 关闭弹出层
            //    layer.close(index);
            //    var iframeIndex = parent.layer.getFrameIndex(window.name);
            //    parent.layer.close(iframeIndex);
            //});

            return false;
        });

    });
</script>



